const { no, ok, getClientIp } = require('../../utils/utlis');
const messageService = require('../../services/client/messageService');
const JWT = require('../../utils/jwt');
module.exports = {
	messageDdd: async (req, res, next) => {
		try {
			let ip = getClientIp(req);

			let token = JWT.decrypt(req.headers.token);
			let { id: userId } = token;
			let { email, content } = req.body;

			await messageService.messageDdd(email, content, ip, userId);
			res.send(ok());
		} catch (error) {
			res.send(no(error.message));
		}
	}
};
